home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Help !!!!! on 'strstr"
- Date: Wed, 13 Mar 96 20:17:21 GMT
- Organization: none
- Distribution: world
- Message-ID: <826748241snz@genesis.demon.co.uk>
- References: <314703FF.4045@msmail.st.stems.com> <TANMOY.96Mar13090728@qcd.lanl.gov>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <TANMOY.96Mar13090728@qcd.lanl.gov>
- tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes:
-
- >On a side issue, is anybody aware of a real locale where, given
- >unsigned chars c1 and c2,
- >
- > (toupper(c1) == toupper(c2)) || (tolower(c1) == tolower(c2))
- >
- >is better than
- >
- > toupper(c1) == toupper(c2)
- >
- >? (I am reasonably sure that I do not want to check whether
- >toupper(tolower(x))'s match, but I always wondered about this one.)
-
- I believe tolower(c1) == tolower(c2) (all arguments apply equivalently to
- toupper).
-
- 7.3.2.1 The tolower function
-
- "If the argument is a character for which isupper is true and there is a
- corresponding character for which islower is true, the tolower function
- returns the corresponding character; otherwise, the argument is returned
- unchanged."
-
- The determining factor is whether in this context 'corresponds' is
- a commutative relation. If so (and I believe that is implicit in its meaning)
- then tolower(x) is guaranteed to be the same as tolower(toupper(x)). There
- are curious cases possible i.e.
-
- 1. An uppercase character has no corresponding lowercase value.
-
- 2. A lowercase character has no corresponing uppercase value.
-
- 3. A character is both uppercase and lowercase.
-
- However in all of these cases neither toupper() nor tolower() can change
- the character. The 'normal' cases (i.e. those found in the "C" locale) are:
-
- 4. A character is neither uppercase nor lowercase
-
- Again toupper() and tolower() must leave this unchanged.
-
- 5. A 'corresponding' pair of characters exists where one is uppercase only
- and the other is lowercase only.
-
- Given one of these characters toupper() and tolower() can only map it to
- itself or to the corresponding one. The function used determines which you
- get out irrespective of which you give it. Therefore in a sequence of
- toupper/tolower mappings only the last one executed can affect the
- final result.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-